package com.itheima.exerciseTest.method20_29.method24;

import java.util.concurrent.locks.ReentrantLock;

public class Cooker implements Runnable {
    private Desk desk;
    private static final ReentrantLock lock = new ReentrantLock();
    private int count = 10;

    public Cooker(Desk desk) {
        this.desk = desk;
    }

    @Override
    public void run() {
        while (count > 0) {
            count--;
            //lock.lock();
            try {
                System.out.println(Thread.currentThread().getName() + "号厨师正在做汉堡包");
                desk.getAbq().put("汉堡包");
            } catch (InterruptedException e) {
                e.printStackTrace();
            } finally {
                //lock.unlock();
            }
        }
    }
}
